﻿<local:KeyedWindowBase x:Class="AddTokenView"
                       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                       xmlns:local="clr-namespace:RawExplorer2.UI"
                       Title="Add Token"
                       Width="500"
                       Height="300"
                       MinWidth="300"
                       MinHeight="200"
                       TextOptions.TextFormattingMode="Display">
	<Window.DataContext>
		<local:AddTokenVm />
	</Window.DataContext>
	<Window.Resources>
		<SolidColorBrush x:Key="GridLineBrush" Color="LightGray" />
	</Window.Resources>
	<Grid Margin="4">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
			<RowDefinition Height="Auto" />
		</Grid.RowDefinitions>
		<Grid Grid.Row="0">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto" />
				<ColumnDefinition Width="*" />
			</Grid.ColumnDefinitions>
			<TextBlock Margin="4" VerticalAlignment="Center">Filter:</TextBlock>
			<TextBox Grid.Column="1"
			         Margin="4"
			         Text="{Binding Path=FilterText,
			                        Mode=TwoWay,
			                        UpdateSourceTrigger=PropertyChanged,
			                        Delay=500}">
				<TextBox.Template>
					<ControlTemplate TargetType="{x:Type TextBox}">
						<Border x:Name="Border"
						        Background="{TemplateBinding Background}"
						        BorderBrush="{TemplateBinding BorderBrush}"
						        BorderThickness="{TemplateBinding BorderThickness}"
						        Padding="2">
							<Grid x:Name="LayoutGrid">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="*" />
									<ColumnDefinition Width="Auto" />
								</Grid.ColumnDefinitions>
								<ScrollViewer x:Name="PART_ContentHost"
								              Grid.Column="0"
								              VerticalAlignment="Center" />
								<Button x:Name="PART_SearchIconBorder"
								        Grid.Column="1"
								        HorizontalAlignment="Stretch"
								        VerticalAlignment="Stretch"
								        Background="Transparent"
								        BorderThickness="0"
								        Command="{Binding Path=ClearFilterCommand}"
								        Padding="1">
									<Image x:Name="SearchIcon"
									       Width="16"
									       Height="16"
									       HorizontalAlignment="Center"
									       VerticalAlignment="Center"
									       Source="../../Icons/DeleteHS.png" />
								</Button>

							</Grid>
						</Border>
					</ControlTemplate>
				</TextBox.Template>
			</TextBox>
		</Grid>
		<StackPanel Grid.Row="1" Orientation="Horizontal">
			<CheckBox Margin="4"
			          IsChecked="True"
			          Visibility="Collapsed">
				Show only tokens for the selected object
			</CheckBox>
		</StackPanel>
		<DataGrid Grid.Row="2"
		          Margin="4"
		          AutoGenerateColumns="False"
		          CanUserAddRows="False"
		          CanUserDeleteRows="False"
		          HorizontalGridLinesBrush="{StaticResource GridLineBrush}"
		          ItemsSource="{Binding Path=FilteredTokens}"
		          SelectionMode="Single"
		          VerticalGridLinesBrush="{StaticResource GridLineBrush}"
		          VirtualizingPanel.IsVirtualizing="True"
		          VirtualizingPanel.ScrollUnit="Pixel">
			<DataGrid.Columns>
				<DataGridTextColumn Width="Auto"
				                    Binding="{Binding Path=Name}"
				                    Header="Token" />
				<DataGridTemplateColumn Width="*" Header="Description">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBlock MaxHeight="200"
							           Text="{Binding Path=Description}"
							           TextTrimming="CharacterEllipsis"
							           TextWrapping="Wrap" />
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
			</DataGrid.Columns>
		</DataGrid>
		<StackPanel Grid.Row="3"
		            Margin="4"
		            HorizontalAlignment="Right"
		            Orientation="Horizontal">
			<Button Width="72"
			        Margin="0,0,8,0"
			        Command="{Binding Path=AddTokenCommand}"
			        IsDefault="True">
				Insert
			</Button>
			<Button Width="72" IsCancel="True">Cancel</Button>
		</StackPanel>
	</Grid>
</local:KeyedWindowBase>
